<?php



namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Support\Facades\Log;

class SnapshotCreatedEvent  implements  ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public  $coverUrl;

    public $snapshots;

    public $videoId;


    /**
     * SnapshotCreatedEvent constructor.
     * @param string $coverUrl
     * @param array $snapshots
     */
    public function __construct(string $coverUrl, array $snapshots ,string  $videoId)
    {

        Log::info(json_encode($snapshots));
        $this->coverUrl = $coverUrl;
        $this->snapshots = $snapshots;
        $this->videoId = $videoId;


    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     *
     * @codeCoverageIgnore
     */
    public function broadcastOn()
    {
        return new Channel('snapshot_created');
    }

    /**
     * @return string
     */
    public function broadcastAs()
    {

        return 'SnapshotCreatedEvent';
    }
}
